package codingforgreat.lchot150;

public class Lc328 {
    public class ListNode {
        int val;
        ListNode next;
        ListNode() {}
        ListNode(int val) { this.val = val; }
        ListNode(int val, ListNode next) { this.val = val; this.next = next; }
    }
    public ListNode oddEvenList(ListNode head) {
        ListNode ji = new ListNode(-1),p1 = ji;
        ListNode ou = new ListNode(-1),p2 = ou;
        ListNode p = head;
        boolean f = true;
        while(p != null){
            if(f){
                ji.next = p;
                ji = ji.next;
            }else{
                ou.next = p;
                ou = ou.next;
            }
            p = p.next;
            f = !f;
        }
        ou.next = null;
        ji.next = p2.next;
        return p1.next;
    }
}
